<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="com.sims.user.UserDAO"%>
<%@ page import="com.sims.vo.UserType"%>

<html>
<head>
	<title>学生信息管理系统</title>
	
	<link rel="stylesheet" href="/sims/css/sims_main.css" type="text/css" />
	<link rel="stylesheet" href="/sims/css/sims_tab.css" type="text/css" />
	<link rel="stylesheet" href="/sims/css/sims_table.css" type="text/css" />

	<style type="text/css">
		p {color: white;font-weight: bold;}
	</style>
</head>

<body>
		<% 
		    String userName=(String)session.getAttribute("username");
			int[] userrights = (int[])session.getAttribute("userrights");
			UserDAO ud = new UserDAO();
			
			UserType result = (UserType)session.getAttribute("userType");
			int[] rights = (int[])session.getAttribute("userRights");
			
		    if (userName != null && ud.checkUserInfo(userName))
		    {
		%>
		    	<div id="header">
				<span id="logoTxt" class="logo">&nbsp;学生信息管理系统</span>
				<span id="loginname" class="username">当前用户：
				<%
					out.println(userName);
				%>
				&nbsp;&nbsp;</span>
				<a class="logout" href="/sims/pages/logout.jsp">注销</a>
				</div>

				<div id="menu">
				<ul id="tab">
					<% 
						if (userrights[0]==1)
						{
					%>
					<li><a href="/sims/pages/default.jsp">信息管理</a></li>
					<% 
						}
						if (userrights[1]==1)
						{
					%>
					<li><a href="/sims/pages/changepwd.jsp">密码管理</a></li>
					<% 
						}
						if (userrights[2]==1)
						{
					%>
					<li><a href="/sims/pages/right.jsp">权限管理</a></li>
					<% 
						}
					%>
				</ul>
				</div>

				<div id="content">
					<%
						
						if (result!=null)
						{
					%>
					<form action="saverole.do" method="POST">
					<table align="left" style="margin-left: 10px;">
					<tr>
 					  	<td>
 					  		<input type="submit" value ="保&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;存"/>
 					  		<input type="button" value ="返&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;回" onClick="location.href='right.jsp'"/>
  					 	</td>
					</tr>
					<tr>
   						<th>角色编号<input required type="text" maxlength="10" name="roleid" placeholder="请输入一位数字" style="width:275px;margin-left: 25px;" 
   						value=<%=result.getUserTypeId()%> readonly="readonly"></th>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<th>角色名称<input required type="text" maxlength="20" name="rolename" placeholder="角色名称" style="width:275px;margin-left: 25px;" 
   						value=<%=result.getUserTypeName()%>></th>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<th>角色权限
   							<input type="checkbox" name="roleright" value="info" style="margin-left: 15px;"
   							<%
   								if (rights[0]==1)
   								{
   							%>
   									checked="checked";
   							<%
   								}
   							%>
   							>信息管理
   							<input type="checkbox" name="roleright" value="pwd"
   							<%
   								if (rights[1]==1)
   								{
   							%>
   									checked="checked";
   							<%
   								}
   							%>
   							>密码管理
   							<input type="checkbox" name="roleright" value="right"
   							<%
   								if (rights[2]==1)
   								{
   							%>
   									checked="checked";
   							<%
   								}
   							%>
   							>权限管理
   						</th>
					</tr>
					<tr>
					   	<td></td>
					</tr>
					<tr>
					   	<td></td>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
					   	<th>角色描述<input type="text" maxlength="20" name="roledesc" placeholder="角色描述" style="width:275px;margin-left: 25px;"
					   	value=<%=result.getUserDescription()%>></th>
					</tr>
					<tr>
					   	<td></td>
					</tr>
					<tr>
					   	<td></td>
					</tr>
					<tr>
					   	<td></td>
					</tr>
					<tr>
					   	<td>
					   	<% 
						String errMsg = (String)request.getSession().getAttribute("Message");
						if (errMsg != null)
						{
							out.println(errMsg);
							request.getSession().removeAttribute("Message");
						}
						else
						{
							out.println("");
						}
						%>
					   	</td>
					</tr>
					</table>
					</form>
					<%
						}
						else
						{
							response.sendRedirect("/sims/right.jsp");
						}
					%>
				</div>

				<div id="footer">Copyright no right</div>
				
				
		<%
		    }
		    else
		    {
		    	response.sendRedirect("/sims/index.jsp");
		    }
		%>		
</body>
</html>